<template>
	<div class="category-content">
		<div class="main-width">
			<div class="category-breadcrumb">
				<a class="category-breadcrumb-default" @click="closeBread(0)">全部商品</a>
				<span class="category-breadcrumb-level-wrap category-haschild" v-for="(item, index) in breadcrum" @click="closeBread(item.deep)">
					<a class="category-breadcrumb-level">{{item.name}}</a>
				</span>
			</div>
			<div class="category-select">
				<div class="category-select-block" :class="{'display-none': conditionShow.one}">
					<div class="category-select-block-name">一级分类:</div>
					<ul :class="{'more': more.one}">
						<li @click="setcate(item.id, item.deep)" v-for="item in categoryOneData" :class="{'select_category':item.isSelect}">{{item.name}}</li>
					</ul>
					<span class="category-select-more category-select-btn" :class="{'display-none': more.one}" @click="open(1)">更多</span>
					<span class="category-select-less category-select-btn" :class="{'display-none': !more.one}" @click="open(1)">收起</span>
				</div>
				<div class="category-select-block" :class="{'display-none': conditionShow.two}">
					<div class="category-select-block-name">二级分类:</div>
					<ul :class="{'more': more.two}">
						<li @click="setcate(item.id, item.deep)" v-for="item in categoryTwoData" :class="{'select_category':item.isSelect}">{{item.name}}</li>
					</ul>
					<span class="category-select-more category-select-btn" :class="{'display-none': more.two}" @click="open(2)">更多</span>
					<span class="category-select-less category-select-btn" :class="{'display-none': !more.two}" @click="open(2)">收起</span>
				</div>
				<div class="category-select-block category-select-brand" :class="{'display-none': conditionShow.three}">
					<div class="category-select-block-name">品牌:</div>
					<span class="category-select-more category-select-btn" :class="{'display-none': more.three}" @click="open(3)">更多</span>
					<span class="category-select-less category-select-btn" :class="{'display-none': !more.three}" @click="open(3)">收起</span>
					<ul :class="{'more': more.three}">
						<li v-for="item in brandData" :class="{'select_category_brand': item.isSelect}" @click="setBracdSelect(item.id)">
							<img :src="imgAddress + item.logoPath" @error="error(3)"/>
						</li>
					</ul>
				</div>
				<div class="category-select-block" v-bind:class="{'display-none': conditionShow.four}">
					<div class="category-select-block-name">三级分类:</div>
					<ul :class="{'more': more.four}">
						<li @click="setcate(item.id, item.deep)" v-for="item in categoryThreeData" :class="{'select_category':item.isSelect}">{{item.name}}</li>					
					</ul>
					<span class="category-select-more category-select-btn" :class="{'display-none': more.four}" @click="open(4)">更多</span>
					<span class="category-select-less category-select-btn" :class="{'display-none': !more.four}" @click="open(4)">收起</span>
				</div>
				<div class="category-select-block">
						<div class="category-select-block-name">含税筛选：</div>
						<ul>
							<li>
								<span class="category-check-item" @click="setTaxData(0)">
									<span class="category-check-default" :class="{'category-check': condition.taxData == 0}"></span>
									全部
								</span>
							</li>
							<li>
								<span class="category-check-item" @click="setTaxData(2)">
									<span class="category-check-default" :class="{'category-check': condition.taxData == 2}"></span>
									含税
								</span>
							</li>
							<li>
								<span class="category-check-item" @click="setTaxData(1)">
									<span class="category-check-default" :class="{'category-check': condition.taxData == 1}"></span>
									不含税
								</span>
							</li>
						</ul>
				</div>
				<div class="category-select-block border-bottom-none">
					<div class="category-select-block-name">条件筛选：</div>
					<ul>
						<li>
							<span class="category-filter-condition-item section">
								<a @click="setOrderRule(2)">佣金</a>
								<div class="section-wrap">
									<div>
										<input type="text" v-model="commissionSectionMin">
									</div>
									<div class="line">
										——
									</div>
									<div>
										<input type="text" v-model="commissionSectionMax">
									</div>
								</div>
							</span>
						</li>
						<li>
							<span class="category-filter-condition-item section">
								<a @click="setOrderRule(3)">价格</a>
								<div class="section-wrap">
									<div>
										<input type="text" v-model="priceSectionMin">
									</div>
									<div class="line">
										——
									</div>
									<div>
										<input type="text" v-model="priceSectionMax">
									</div>
								</div>
							</span>
						</li>
						<li>
							<span class="category-filter-condition-item section">
								<a @click="setOrderRule(4)">利润率</a>
								<div class="section-wrap">
									<div>
										<input type="text" v-model="condition.profitSectionMin">
									</div>
									<div class="line">
										——
									</div>
									<div>
										<input type="text" v-model="condition.profitSectionMax">
									</div>
								</div>
							</span>
						</li>
						<li>
							<el-button class="section-init" :style="{'border-color': colorMain,'background': colorMain}" @click="sectionInit">确定</el-button>
						</li>
					</ul>
				</div>
			</div>


			<div class="category-filter-condition">
				<span class="category-filter-condition-item" @click="setOrderRule(1)" :class="{'category-filter-condition-select': filter.time.isSelect}" >最新</span>
				<!--<span class="category-filter-condition-item category-filter-condition-select">销量</span>-->
				<span class="category-filter-condition-check" @click="hideGoods" :class="{'ischecked': condition.hideGoods}">隐藏已上架产品</span>
				<span class="category-filter-condition-page">
					<span>{{condition.pageNum}}</span>/<span>{{pageCount}}</span>
					<span class="category-filter-condition-prev category-filter-page-default" @click="prev"></span>
					<span class="category-filter-condition-next category-filter-page-default" @click="next"></span>
				</span>

				<el-button class="float-right" @click="pushAll">批量加入货架</el-button>
			</div>
			<div class="category-goods-wrap" v-show="hasGoods">
				<ul class="category-goods-list">
					<li class="category-goods-item" v-for="(item, index) in goodsList">
						<div  class="category-goods-image" @mouseenter="showMask(index)" @mouseleave="hideMask(index)">
							<router-link tag="a" target="_blank" :to="{name: 'Detail', query: {goodsId: item.goodsId}}">
								<img :src="imgAddress + item.goodsImage" @error="error(1)" />
								<div class="category-hover-product" :class="{'display-none':maskShow[index].isShow}">
									<table>
										<thead>
											<tr>
												<th>SKU</th>
												<th>
													<span v-if="globalIsBill == 0">不含税结算价</span>
													<span v-else>含税结算价</span>
													(+运费)
												</th>
												<th>库存</th>
											</tr>
										</thead>
										<tbody>
											<tr v-for="(value, index) in item.products" v-if="index < 5">
												<td class="category-table-SKU"><div>{{value.specName}}</div></td>
												<td>
													<span v-if="globalIsBill == 0">{{value.noTaxSettlementPrice/100}}<span class="freight-price">(+{{value.freight/100}})</span></span>
													<span v-else>{{value.taxSettlementPrice/100}}<span class="freight-price">(+{{value.freight/100}})</span></span>
												</td>
												<td>
													<span v-if="globalIsBill == 0">{{value.inventoryNum}}</span>
													<span v-else>{{value.taxInventoryNum}}</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</router-link>
						</div>
						<div class="category-goods-money">
							利润率：
							<span v-if="globalIsBill == 0">{{item.profitMargin}}</span>
							<span v-else>{{item.taxProfitMargin}}</span>
							%
						</div>
						<div class="category-goods-info">
							<div class="category-goods-price">
								¥{{item.salePrice/100}}
								<span v-if="globalIsBill == 0">佣金：¥{{item.commission/100}}</span>
								<span v-else>佣金：¥{{item.taxCommission/100}}</span>
							</div>
							<el-tooltip class="item" effect="dark"  placement="top">
								<div slot="content">{{item.goodsName}}</div>
								<div class="category-goods-title channel-dianshang" v-if="item.channel == 1">{{item.goodsName}}</div>
								<div class="category-goods-title channel-mendian" v-else-if="item.channel == 2">{{item.goodsName}}</div>
								<div class="category-goods-title channel-haitao" v-else>{{item.goodsName}}</div>
							</el-tooltip>
						</div>
						<div v-if="globalIsBill == 0">
							<div class="category-goods-add-default yishangjia" v-if="noInventoryNum[index].haskc == 0">暂无库存</div>
							<div class="category-goods-add-default" v-else-if="item.shelves == 0" @click="addGoodsAll(index, item.goodsId)">加入货架</div>
							<div class="category-goods-add-default yishangjia" v-else>已加入货架</div>
						</div>
						<div v-else>
							<div class="category-goods-add-default yishangjia" v-if="noTaxInventoryNum[index].haskc == 0">暂无库存</div>
							<div class="category-goods-add-default" v-else-if="item.shelves == 0" @click="addGoodsAll(index, item.goodsId)">加入货架</div>
							<div class="category-goods-add-default yishangjia" v-else>已加入货架</div>
						</div>
					</li>
				</ul>
				<div class="block">
					<el-pagination layout="prev, pager, next" @current-change="handleCurrentChange" :current-page.sync="condition.pageNum" :total="goodsListCount" :page-size="30"></el-pagination>
				</div>
			</div>
			<div class="category-goods-wrap-no" v-show="!hasGoods">
				<div class="category-goods-wrap-tip">没有找到相关商品...</div>
			</div>	
		</div>
	</div>
</template>
<script>
	import store from '../store/index.js'
	import {addShelves, search, imgAddress} from '../config/interface.js'
	import {toast, imageError} from '../util/tool.js'
	import {fetch} from '../config/fetch.js'
	import router from '../router/index.js'
	import {mapActions} from 'vuex'

	export default {
		data(){
			return {
				condition: {
					keyWord: '',
					selectType: '1',
					categoryOne: '',
					categoryTwo: '',
					categoryThree: '',
					orderRule: '',
					brandIds: [],
					hideGoods: 0,
					pageNum: 1,
					pageSize: 30,
					commissionSectionMax: '',
					commissionSectionMin: '',
					priceSectionMax: '',
					priceSectionMin: '',
					profitSectionMax: '',
					profitSectionMin: '',
					userId: store.state.userId,
					taxData: 0
				},
				commissionSectionMax: '',
				commissionSectionMin: '',
				priceSectionMax: '',
				priceSectionMin: '',
				goodsList: {},
    			categoryOneData: {},
    			categoryTwoData: {},
    			categoryThreeData: {},
    			brandData: {},
    			filter: {
    				time: {
    					id: 1,
    					isSelect: true
    				},
    				money: {
    					id: 2,
    					isSelect: false
    				},
    				price: {
    					id: 3,
    					isSelect: false
    				},
    				profit: {
    					id: 4,
    					isSelect: false
    				}
    			},
    			breadcrum: [],
    			more: {
    				one: false,
    				two: false,
    				three: false,
    				four: false
    			},
    			conditionShow: {
    				one: false,
    				two: true,
    				three: true,
    				four: true,
    			},
    			maskShow: {},
    			goodsListCount: 0,
    			pageCount: '',
    			brandName: '',
    			deep: [
    				{
    					deepOne: ''
    				},
    				{
    					deepTwo: ''
    				},
    				{
    					deepThree: ''
    				},
    			],
    			imgAddress: imgAddress,
    			hasGoods: true,
    			noInventoryNum: {},
	    		noTaxinventoryNum: {},
	    		colorMain: store.state.colorMain
			}
		},
		created(){
			this.condition.categoryOne = this.$route.query.levelOne;
			this.condition.categoryTwo = this.$route.query.levelTwo;
			this.condition.categoryThree = this.$route.query.levelThree;
			this.condition.keyWord = this.$route.query.keyWord;
			this.condition.selectType = this.$route.query.selectType;
			var arr = [];
			if(this.$route.query.brandId != ''){
				arr.push(this.$route.query.brandId);				
			}
			this.condition.brandIds = arr;			
		},
		computed: {
	      	globalIsBill() {
	      		return this.$store.state.isBill
	      	}
		},
		watch: {
          // 如果路由有变化，会再次执行该方法
          "$route": "routeChange",
          globalIsBill (val) {
	    		var that = this;
	    		that.inventoryNum();
		      console.log('this.isBill='+val);
		  } 
        },
		mounted(){
			this.init();
		},
		methods: {
			...mapActions({ setGoodsCount: 'setGoodsCount' }),
			error(num){
				imageError(num, event);
			},
			routeChange(){
				this.condition.categoryOne = this.$route.query.levelOne;
				this.condition.categoryTwo = this.$route.query.levelTwo;
				this.condition.categoryThree = this.$route.query.levelThree;
				this.condition.keyWord = this.$route.query.keyWord;
				this.condition.selectType = this.$route.query.selectType;
				var arr = [];
				if(this.$route.query.brandId != ''){
					arr.push(this.$route.query.brandId);				
				}
				this.condition.brandIds = arr;
				this.init();
			},
			handleCurrentChange(val) {
		        this.condition.pageNum = val;
		        this.init();
		    },
			init(){
				var that = this;
				var data = this.condition;
				var url = search;
				fetch(url, data)
				.then(res => {
					var categoryOne = this.condition.categoryOne;
					var categoryTwo = this.condition.categoryTwo;
					var categoryThree = this.condition.categoryThree;
					var brand = this.condition.brandIds[0];
					this.goodsList = res.data.goods;

					if(this.goodsList.length == 0){
						this.hasGoods = false;
					}else{
						this.hasGoods = true;
					}

					var arr = [];
					for(var i = 0; i < this.goodsList.length; i++){
						var opt = {
							isShow: true
						};
						arr.push(opt);
					}					
					this.maskShow = arr;

					this.categoryOneData = this.initCateValue(0, categoryOne, res.data.categoryOne);
					this.categoryTwoData = this.initCateValue(1, categoryTwo, res.data.categoryTwo);
					this.categoryThreeData = this.initCateValue(2, categoryThree, res.data.categoryThree);
					this.brandData = this.initBrandValue(brand, res.data.brand);
					this.goodsListCount = res.data.goodsCount;
					this.pageInit();

					var arr1 = [];
					var categoryOneId = res.data.breadLine.categoryOneId;
					var categoryOneName = res.data.breadLine.categoryOneName;
					var categoryTwoId = res.data.breadLine.categoryTwoId;
					var categoryTwoName = res.data.breadLine.categoryTwoName;
					var categoryThreeId = res.data.breadLine.categoryThreeId;
					var categoryThreeName = res.data.breadLine.categoryThreeName;
					var name = this.brandName ;
					
					if(categoryOneId == ''&&categoryTwoId==''&&categoryThreeId==''&&name == ''){
						this.breadcrum = arr1;
						this.conditionShow.one = false;
		    		 	this.conditionShow.two = true;
		    		 	this.conditionShow.three = true;
		    		 	this.conditionShow.four = true;
					}else if(categoryOneId != ''&&categoryTwoId==''&&categoryThreeId==''&&name == ''){
						var opt = {
							name: categoryOneName,
	    		 			deep: 1
						}
						arr1.push(opt);
						this.breadcrum = arr1;
						this.conditionShow.one = false;
		    		 	this.conditionShow.two = false;
		    		 	this.conditionShow.three = true;
		    		 	this.conditionShow.four = true;
					}else if(categoryOneId != ''&&categoryTwoId!=''&&categoryThreeId==''&&name == ''){
						var opt = {
							name: categoryOneName,
	    		 				deep: 1
						};
						var obj = {
							name: categoryTwoName,
	    		 				deep: 2
						}
						arr1.push(opt);
						arr1.push(obj);
						this.breadcrum = arr1;
						this.conditionShow.one = true;
		    		 	this.conditionShow.two = true;
		    		 	this.conditionShow.three = false;
		    		 	this.conditionShow.four = false;
					}else if(categoryOneId != ''&&categoryTwoId!=''&&categoryThreeId !=''&&name == ''){
						var opt = {
							name: categoryOneName,
	    		 				deep: 1
						};
						var obj = {
							name: categoryTwoName,
	    		 				deep: 2
						}
						var o = {
							name: categoryThreeName,
	    		 				deep: 3
						}
						arr1.push(opt);
						arr1.push(obj);
						arr1.push(o);
						this.breadcrum = arr1;
						this.conditionShow.one = true;
		    		 	this.conditionShow.two = true;
		    		 	this.conditionShow.three = false;
		    		 	this.conditionShow.four = false;
					}else if(categoryOneId != ''&&categoryTwoId!=''&&categoryThreeId ==''&&name != ''){
						var opt = {
							name: categoryOneName,
	    		 				deep: 1
						};
						var obj = {
							name: categoryTwoName,
	    		 				deep: 2
						}
						var o = {
							name: name,
	    		 				deep: 3
						}
						arr1.push(opt);
						arr1.push(obj);
						arr1.push(o);
						this.breadcrum = arr1;
						this.conditionShow.one = true;
		    		 	this.conditionShow.two = true;
		    		 	this.conditionShow.three = false;
		    		 	this.conditionShow.four = false;
					}else if(categoryOneId != ''&&categoryTwoId!=''&&categoryThreeId !=''&&name != ''){
						var opt = {
							name: categoryOneName,
	    		 				deep: 1
						};
						var obj = {
							name: categoryTwoName,
	    		 				deep: 2
						}
						var o = {
							name: name + ' ' + categoryThreeName,
	    		 				deep: 3
						}
						arr1.push(opt);
						arr1.push(obj);
						arr1.push(o);
						this.breadcrum = arr1;
						this.conditionShow.one = true;
		    		 	this.conditionShow.two = true;
		    		 	this.conditionShow.three = false;
		    			this.conditionShow.four = false;
					} 

					that.inventoryNum();			
	            });
			},
			inventoryNum(){
				var arr2 = [];
				if(this.globalIsBill == 0){
					for(var i = 0; i < this.goodsList.length; i++){
						var item = this.goodsList[i];
						var obj = {
							haskc: 0
						};
						for(var j = 0; j < item.products.length; j++){
							if(item.products[j].inventoryNum != 0){
								obj.haskc = 1;
							}								
						}
						arr2.push(obj);
					}
					this.noInventoryNum = arr2;
				}else{
					for(var i = 0; i < this.goodsList.length; i++){
						var item = this.goodsList[i];
						var obj = {
							haskc: 0
						};
						for(var j = 0; j < item.products.length; j++){
							if(item.products[j].taxInventoryNum != 0){
								obj.haskc = 1;
							}								
						}
						arr2.push(obj);
					}
					this.noTaxInventoryNum = arr2;
				}
			},
			initCateValue(index,value,arr){
	    		var list = [];
	    		for(var i = 0; i < arr.length; i++){
	    			if(value == arr[i].categoryId){	
	    				var opt = {
	    					id: arr[i].categoryId,
	    					name: arr[i].name,
	    					parentId: arr[i].parentId,
	    					deep: arr[i].deep,
	    					isSelect: true
	    				}
	    			}else{
	    				var opt = {
	    					id: arr[i].categoryId,
	    					name: arr[i].name,
	    					parentId: arr[i].parentId,
	    					deep: arr[i].deep,
	    					isSelect: false
	    				}
	    			}
	    			list.push(opt);
	    		}		    		
	    		return list;
		    },
		    initBrandValue: function(value,arr){
	    		var list = [];
	    		for(var i = 0; i < arr.length; i++){
	    			if(value == arr[i].brandId){			    				
	    				var opt = {
	    					id: arr[i].brandId,
	    					name: arr[i].brandName,
	    					logoPath: arr[i].logoPath,		    					
	    					isSelect: true
	    				}
	    				this.brandName = arr[i].brandName;
	    			}else{
	    				var opt = {
	    					id: arr[i].brandId,
	    					name: arr[i].brandName,
	    					logoPath: arr[i].logoPath,		    					
	    					isSelect: false
	    				}
	    			}
	    			list.push(opt);
	    		}		    		
	    		return list;
		    },
		    setBracdSelect: function(id){		    		
	    		var conditionBrand = this.condition.brandIds[0];
	    		var brandData = this.brandData;
	    		var name = '';
	    		for(var i = 0; i < brandData.length; i++){
	    			if(id == brandData[i].id){
	    				name = brandData[i].name;
	    			}
	    		}			    			    		
	    		if(id == conditionBrand){
	    			this.condition.brandIds = [];
	    			this.brandName = '';
	    		}else{
	    			var brand = [id];
	    			this.brandName = name;
	    			this.condition.brandIds = brand;
	    		}
	    		this.init();
		    },
		    setOrderRule: function(id){
	    		var filter = this.filter;
	    		for(var i in filter){
	    			if(filter[i].id == id){
	    				filter[i].isSelect = true;
	    				this.condition.orderRule = id;
	    			}else{
	    				filter[i].isSelect = false;
	    			}
	    		}
	    		this.condition.pageNum = 1;
	    		this.init();
		    },
		    hideGoods: function(){			    		
	    		var hideGoods = this.condition.hideGoods;
	    		if(hideGoods == 0){
	    			this.condition.hideGoods = 1;
	    		}else{
	    			this.condition.hideGoods = 0;
	    		}
	    		this.condition.pageNum = 1;
	    		this.init();
		    },
		    setcate: function(id, deep){
	    		if(deep == 1){
	    			this.condition.categoryOne = id;
	    		 	this.condition.categoryTwo = '';
	    		 	this.condition.categoryThree = '';			    		 	
	    		 	this.conditionShow.one = false;
	    		 	this.conditionShow.two = false;
	    		 	this.conditionShow.three = true;
	    		 	this.conditionShow.four = true;
	    		}else if(deep == 2){
	    		 	this.condition.categoryTwo = id;
	    		 	this.condition.categoryThree = '';			    		 				    		 	
	    		 	this.conditionShow.one = true;
	    		 	this.conditionShow.two = true;
	    		 	this.conditionShow.three = false;
	    		 	this.conditionShow.four = false;
	    		}else if(deep == 3){
	    		 	this.condition.categoryThree = id;		    		 		
	    		 	this.conditionShow.one = true;
	    		 	this.conditionShow.two = true;
	    		 	this.conditionShow.three = false;
	    		 	this.conditionShow.four = false;
	    		}
	    		this.init();
		    },
		    closeBread: function(deep){
	    		if(deep == 1){
	    			this.condition.categoryOne = '';
	    		 	this.condition.categoryTwo = '';
	    		 	this.condition.categoryThree = '';		    		 	
	    		 	this.conditionShow.one = false;
	    		 	this.conditionShow.two = true;
	    		 	this.conditionShow.three = true;
	    		 	this.conditionShow.four = true;
	    		}else if(deep == 2){
	    		 	this.condition.categoryTwo = '';
	    		 	this.condition.categoryThree = '';
	    		 	this.conditionShow.one = false;
	    		 	this.conditionShow.two = false;
	    		 	this.conditionShow.three = true;
	    		 	this.conditionShow.four = true;
	    		}else if(deep == 3){
	    			this.condition.categoryThree = '';
	    			this.brandName = '';
	    			this.condition.brandIds = [];
	    		 	this.breadcrum.pop();
	    		 	this.conditionShow.one = true;
	    		 	this.conditionShow.two = true;
	    		 	this.conditionShow.three = false;
	    		 	this.conditionShow.four = false;
	    		}else if(deep == 0){
	    			this.brandName = '';
	    			this.condition.brandIds = [];
	    		 	this.breadcrum.pop();
	    			this.condition.categoryOne = '';
	    		 	this.condition.categoryTwo = '';
	    		 	this.condition.categoryThree = '';		    		 	
	    		 	this.conditionShow.one = false;
	    		 	this.conditionShow.two = true;
	    		 	this.conditionShow.three = true;
	    		 	this.conditionShow.four = true;	
	    		}
	    		this.init();
		    },
		    open: function(id){
	    		if(id==1){
	    			this.more.one = !this.more.one;
	    		}else if(id==2){
	    			this.more.two = !this.more.two;
	    		}else if(id==3){
	    			this.more.three = !this.more.three;			    			
	    		}else {
	    			this.more.four = !this.more.four;
	    		}
		    },
		    showMask: function(index){	    		
	    		this.maskShow[index].isShow = false;
		    },
		    hideMask: function(index){
	    		this.maskShow[index].isShow = true;
		    },
		    addGoodsAll: function(index, goodsId){
				var List = [];
				var tableInfo = this.goodsList[index].products;
				for(var i in tableInfo){
					var goodsItem = {};
					goodsItem.productId = tableInfo[i].productId;
					goodsItem.goodsId = goodsId;
					goodsItem.hasTax = this.globalIsBill;
					goodsItem.activityDetailId = tableInfo[i].activityDetailId;
					List.push(goodsItem);
				}
				var data = {
					goodsList: List,
					userId: this.condition.userId
				};
				var url = addShelves;
				fetch(url, data)
				.then(res => {
					if(res.code == 10000){
						var str = "上架成功";
	                    toast(str, 1, false);
	                    this.goodsList[index].shelves = 1;
	                    this.setGoodsCount();
					}else{
						var str = "上架失败";
						toast(str, 2, false);
					}                   
                });
			},
			pushAll(){
				var List = [];
				for(var i in this.goodsList){
					var products = this.goodsList[i].products;
					for(var j in products){
						var goodsItem = {};
						goodsItem.productId = products[j].productId;
						goodsItem.hasTax = this.globalIsBill;
						goodsItem.goodsId = this.goodsList[i].goodsId;
						goodsItem.activityDetailId = this.goodsList[i].products[j].activityDetailId;
						List.push(goodsItem);
					}
				}
				var data = {
					goodsList: List,
					userId: this.condition.userId
				};
				var url = addShelves;
				fetch(url, data)
				.then(res => {
					if(res.code == 10000){
						var str = "上架成功";
	                    toast(str, 1, false);
	                    this.init();
	                    this.setGoodsCount();
					}else{
						var str = "上架失败";
						toast(str, 2, false);
					}                   
                });

			},
			pageInit(){
				var pageCount = Math.ceil(this.goodsListCount / 30);
				this.pageCount = pageCount;
			},
			prev(){
				if(this.condition.pageNum > 1){
					this.condition.pageNum = this.condition.pageNum - 1;
				}
			},
			next(){
				if(this.condition.pageNum < this.pageCount){
					this.condition.pageNum = this.condition.pageNum + 1;
				}
			},
			sectionInit(){
				this.condition.commissionSectionMax = this.commissionSectionMax * 100;
				this.condition.commissionSectionMin = this.commissionSectionMin * 100;
				this.condition.priceSectionMax = this.priceSectionMax * 100;
				this.condition.priceSectionMin = this.priceSectionMin * 100;
				this.init();
			},
			setTaxData: function(taxData){
	    		this.condition.taxData = taxData;
	    		this.init();		    		
		    },
		}
	}
</script>
<style>
</style>